var user = 'johnny';
var pass = 'c-bad';
var authstring  = user + ":" + pass;
var encoded = new Buffer(user + ':' + pass).toString('base64');
console.log(encoded);
//处理data URLs
var fs = require('fs');
var mime = 'image/png';
var encoding = 'base64';
var data = fs.readFileSync('./mm.jpg').toString(encoding);
var uri = 'data:' + mime +';' + encoding + ','+data;
// console.log(uri);

//回显data
var data2 = uri.split(',')[1];
var buf2 = new Buffer.from(data2,'base64');
fs.writeFileSync('./mm2.jpg',buf2);